#include "../include/Resources.h"
#include <iostream>
#include <string>
using namespace std;

Resources::Resources()
{
}

Resources::Resources(ass2::eEnergy type): _type(type), _amount(0), _consumed(0), _created(0){


}
Resources::Resources(ass2::eEnergy type, int amount): _type(type), _amount(amount), _consumed(0), _created(amount){

}

void Resources::create(int amount){
	_amount = _amount + amount;
	_created = _created + amount;
}


void Resources::consume (int amount){
	bool flag = false;
	if (_amount == 0)
		flag = true;
	if (_amount > amount){
		_amount = _amount - amount;
		_consumed = _consumed + amount;
	}
	else
		if (!flag){
			_consumed = _consumed + _amount;
			_amount = 0;
		}
}


void Resources::sell (int amount){
	_amount = _amount - amount;
}


void Resources::buy (int amount){
	_amount = _amount + amount;
}



int Resources::getAmount(){return _amount;}
int Resources::getConsumed (){return _consumed;}
int Resources::getCreated (){return _created;}
ass2::eEnergy Resources::getType (){return _type;}


Resources::~Resources()
{

}
